package jianda;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import javax.print.Doc;
import java.io.File;
import java.io.FileReader;
import java.util.Iterator;

public class Jianda2 {
    public static void main(String[] args) {
        Document document= null;
        try {
            SAXReader reader = new SAXReader();
            document=reader.read(new File("src/jianda/StudentScores.xml"));
        }catch (Exception e){
            e.printStackTrace();
        }
        Element rootElement =document.getRootElement();
        for (Iterator student=rootElement.elementIterator();student.hasNext();){
            Element stu = (Element)student.next();
            System.out.println("\n编号："+stu.attributeValue("id"));
            System.out.println("姓名:"+stu.elementText("name"));
            System.out.println("课程:"+stu.elementText("course"));
            System.out.println("分数:"+stu.elementText("score"));
        }
    }
}
